package SEApp.components
{
	import SEApp.boxes.albums.se_userAvatar;
	import SEApp.se_app;
	
	import UIFree.controls.uif_hscrollAreaA;
	import UIFree.uif_component;
	
	import flash.geom.Rectangle;
	
	public class se_friendList extends uif_hscrollAreaA {
		private var _list: Array;
		public function se_friendList(parent: uif_component, ax:int=0, ay:int=0, awidth:int=0, aheight:int=0, styleClass:String='', a_bwidth:int=0, countInfo:Boolean=true) {
			super(parent, ax, ay, awidth, aheight, styleClass, a_bwidth, countInfo);
			
			seApp.externalServer.getAllFriends(seApp.externalServer.viewer_id, doFriendComplete);
		}
		
		public function get seApp(): se_app {
			return app as se_app;
		}
		
		override protected function get scrollStep(): Number {
			return countDisplay;
		}
		
		protected function doFriendComplete(data: Array): void {
			_list = filterList(data);
			assignList(_list, calcFrameWidth(rows), createItem, rows); 
		}
		
		protected function filterList(a_list: Array): Array {
			return a_list;
		}
		
		protected function itemClass(): Class {
			return se_userAvatar;
		}
		
		protected function createItem(_scroll: uif_component, inner: Rectangle, index: int): se_userAvatar {
			return new (itemClass())(_scroll, inner.x, inner.y, inner.width, inner.height, _list[index], style['unselect']);   
		}
	}
}